import React from 'react'
import { Route,Redirect } from 'react-router-dom'
import { useAppContext } from '../context/Appcontext'

const AuthRoute = (props) => {
    const {state} = useAppContext();
    if((state.username==="zhangsan" && state.pwd==="123456") || (state.username==="lisi"&&state.pwd==="1234")){
        return <Route {...props}/>
    }
    return <Redirect to='/login'/>
}
export default AuthRoute